<?php
  /*****************************************************
   * Rapidleech 36B Rv.8
   *
   * $Id: global.php - 05apr2010-Idx $
  *****************************************************/

if(!defined("RAPIDLEECH")){
	die("Direct initialization of this file is not allowed.<br /><br />RAPIDLEECH is not defined.");
}

$working_dir = dirname(__FILE__);
if(!$working_dir){
	$working_dir = '.';
}

// check fileconfig existence
if(!@file_exists("configs/config.php")){

   define('CLASS_DIR', 'classes/');
   define('CONFIG_DIR', 'configs/');
   define('DEFAULT_CONFIG_FILE', $working_dir .'/'.CONFIG_DIR . 'config.default.php');
   require_once DEFAULT_CONFIG_FILE;
   
   define('TEMPLATE_DIR', 'tpl/'.$options['template_used'].'/');
   define('IMAGE_DIR', TEMPLATE_DIR . 'skin/'. $options["csstype"] . '/');
   
   $loca["thisFile"] = str_replace('\\', '/', __FILE__);
   $loca["docRoot"] = $_SERVER['DOCUMENT_ROOT'] . (substr($_SERVER['DOCUMENT_ROOT'],-1) != "/" ? "/":"");
   $webRoot = str_replace(array($loca["docRoot"], '/'.basename(__FILE__) ), '', $loca["thisFile"]);
   unset($loca);
   if($webRoot=="/") $webRoot = "";
   define('ROOT_URL', "http://". $_SERVER["SERVER_NAME"] . "/" . $webRoot);

   $fninstall = $working_dir ."/".CONFIG_DIR . "setup.php";
   if(file_exists($fninstall)) {
     require_once($fninstall);
   }else{
     die("File not found " . $fninstall);
   };
   exit();
}


// Load main core file which begins all initialisation
require_once $working_dir."/classes/init.php";


?>